using System.ComponentModel.DataAnnotations;

namespace GroupSix.Application.Dtos;

/// <summary>
/// 获取用户列表请求DTO
/// </summary>
public class GetUserListRequestDto
{
    public int Page { get; set; } = 1;
    public int PageSize { get; set; } = 20;
    public string? Keyword { get; set; }
    public int? Status { get; set; }
}

/// <summary>
/// 用户列表DTO
/// </summary>
public class UserListDto
{
    public Guid Id { get; set; }
    public string Username { get; set; } = string.Empty;
    public string? Nickname { get; set; }
    public string Email { get; set; } = string.Empty;
    public string? Phone { get; set; }
    public int Status { get; set; }
    public DateTime CreatedAt { get; set; }
    public DateTime? UpdatedAt { get; set; }
    
    /// <summary>
    /// 用户角色列表
    /// </summary>
    public List<UserRoleDto> Roles { get; set; } = new();
}

/// <summary>
/// 创建用户请求DTO
/// </summary>
public class CreateUserRequestDto
{
    [Required(ErrorMessage = "用户名不能为空")]
    [StringLength(50, ErrorMessage = "用户名长度不能超过50个字符")]
    public string Username { get; set; } = string.Empty;

    [StringLength(50, ErrorMessage = "昵称长度不能超过50个字符")]
    public string? Nickname { get; set; }

    [Required(ErrorMessage = "邮箱不能为空")]
    [EmailAddress(ErrorMessage = "邮箱格式不正确")]
    [StringLength(100, ErrorMessage = "邮箱长度不能超过100个字符")]
    public string Email { get; set; } = string.Empty;

    [StringLength(20, ErrorMessage = "手机号长度不能超过20个字符")]
    public string? Phone { get; set; }

    [Required(ErrorMessage = "密码不能为空")]
    [StringLength(100, MinimumLength = 6, ErrorMessage = "密码长度必须在6-100个字符之间")]
    public string Password { get; set; } = string.Empty;

    [StringLength(500, ErrorMessage = "头像URL长度不能超过500个字符")]
    public string? Avatar { get; set; }

    public int Status { get; set; } = 1;
    
    /// <summary>
    /// 角色ID列表
    /// </summary>
    public List<Guid>? RoleIds { get; set; }
    
    /// <summary>
    /// 备注
    /// </summary>
    [StringLength(500, ErrorMessage = "备注长度不能超过500个字符")]
    public string? Remarks { get; set; }
}

/// <summary>
/// 更新用户请求DTO
/// </summary>
public class UpdateUserRequestDto
{
    [Required(ErrorMessage = "用户ID不能为空")]
    public Guid Id { get; set; }

    [StringLength(50, ErrorMessage = "昵称长度不能超过50个字符")]
    public string? Nickname { get; set; }

    [EmailAddress(ErrorMessage = "邮箱格式不正确")]
    [StringLength(100, ErrorMessage = "邮箱长度不能超过100个字符")]
    public string? Email { get; set; }

    [StringLength(20, ErrorMessage = "手机号长度不能超过20个字符")]
    public string? Phone { get; set; }

    [StringLength(500, ErrorMessage = "头像URL长度不能超过500个字符")]
    public string? Avatar { get; set; }

    public int? Status { get; set; }
    
    /// <summary>
    /// 角色ID列表
    /// </summary>
    public List<Guid>? RoleIds { get; set; }
    
    /// <summary>
    /// 备注
    /// </summary>
    [StringLength(500, ErrorMessage = "备注长度不能超过500个字符")]
    public string? Remarks { get; set; }
}

/// <summary>
/// 切换用户状态请求DTO
/// </summary>
public class ToggleUserStatusRequestDto
{
    [Required(ErrorMessage = "状态不能为空")]
    public int Status { get; set; }
} 